﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ClassLibrary1
{
    public class build
    {

        public DataTable buildTable()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Name");
            dt.Columns.Add("Address");
            dt.Columns.Add("City");
            dt.Columns.Add("ZipCode");

            DataRow dr = dt.NewRow();

            dr[0] = "James";
            dr[1] = "1452 unf dr";
            dr[2] = "Jacksonville";
            dr[3] = "32221";

            dt.Rows.Add(dr);

            DataRow dr1 = dt.NewRow();

            dr1[0] = "David";
            dr1[1] = "41 baymeadows blvd";
            dr1[2] = "Jacksonville";
            dr1[3] = "32215";

            dt.Rows.Add(dr1);

            return dt;

        }


        public int GetNumberOfColumns(DataTable dt)
        {
            return dt.Columns.Count;
        }

        public int GetNumberOfRows(DataTable dt)
        {

            return dt.Rows.Count;
        }

        public void SetAllElements(DataTable dt, Element[] els, Record[] r)
        {
            
            for (int j = 0; j < dt.Rows.Count; j++)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    els[i].tagName = dt.Columns[i].Caption;
                    els[i].tagType = dt.Columns[i].DataType;
                    els[i].tableName = dt.Columns[i].Table.TableName;
                    els[i].tagValue = dt.Rows[j][i].ToString();

                }

                r[j].elements = els;
            }


        }

        public void ABC()
        {
            //Select * from Customer
            //execute query and get Dt
            DataTable result = buildTable();
            int numberofElements = GetNumberOfColumns(result);
            int numberOfRecords = GetNumberOfRows(result);

            Element[] allElements = new Element[numberofElements];
            Record[] allRecords = new Record[numberOfRecords];
        }
    }
}
